package com.system.healthproject.model.admin.service.impl;

import com.system.healthproject.bean.PagesBean;
import com.system.healthproject.bean.ResultTransaction;
import com.system.healthproject.mapper.TransactionMapper;
import com.system.healthproject.model.admin.service.TransactionInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 交易信息管理service
 */
@Service
public class TransactionInfoServiceImp implements TransactionInfoService {

    @Autowired
    TransactionMapper transactionMapper;


    /**
     * 后台查询所有用户的交易信息
     * @param currentPage
     * @param limit
     * @param userName
     * @param transactionId
     * @param transactionStartTime
     * @param transactionEndTime
     * @return
     */
    @Override
    public PagesBean<ResultTransaction> selectTransactionList
    (int currentPage, int limit,
     String userName,
     String transactionId,
     String transactionStartTime,
     String transactionEndTime) {
        PagesBean<ResultTransaction> pagesBean = new PagesBean<>();

        List<ResultTransaction> resultTransactions
                = transactionMapper.selectTransactionList(
                (currentPage-1)*limit,limit,userName,transactionId,transactionStartTime,transactionEndTime);
        int total = transactionMapper.getTotal(currentPage,limit,userName,transactionId,transactionStartTime,transactionEndTime);
        pagesBean.setData(resultTransactions);
        pagesBean.setNowsPage(currentPage);
        pagesBean.setPageSize(limit);
        pagesBean.setDataCount(total);
        return pagesBean;
    }
}
